package dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import to.BeansTO;
import to.JobTO;
import to.MachineTO;
import to.SiloTO;
import to.WeightTO;

public class CoffeeDAO {
	private SqlMapClientTemplate sqlMap;
	public CoffeeDAO(SqlMapClientTemplate sqlMap){
		this.sqlMap = sqlMap;
	}

	//Machine 진행중레시피 update
	public void updateMachinePrograssRecipe(HashMap map)throws SQLException{
		sqlMap.update("updateMachinePrograssRecipe", map);
	}
	
	//machine 진행중레시피 select
	public String selectMachinePrograssRecipe(String machinName)throws SQLException{
		return (String)sqlMap.queryForObject("selectMachinePrograssRecipe");
	}
	
	//재료 용량 update
	public void updateMaterialTotalWeight(HashMap map)throws SQLException{
		sqlMap.update("updateMaterialTotalWeight", map);
	}
	
	//재료량 select
	public int selectMaterialTotalWeight(String materialName)throws SQLException{
		return (Integer)sqlMap.queryForObject("selectMaterialTotalWeight",materialName);
	}
	
	//검수된 원두의 정보를 update
	public void insertBeansInfo(BeansTO bto)throws SQLException{
//		System.out.println(bto);
		sqlMap.insert("insertBeansInfo",bto);
	}
	
	//silo 상태 update
	public void updateSiloStatus(HashMap map)throws SQLException{
		sqlMap.update("updateSiloStatus", map);
	}
	
	//silo Beans 총중량 select
	public int selectSiloBeansTotalWeight(String siloName)throws SQLException{
		return (Integer)sqlMap.queryForObject("selectSiloBeansTotalWeight",siloName);
	}
	
	//배전두silo BigBeans 총중량 select
	public int selectBigBeansTotalWeight()throws SQLException{
		return (Integer)sqlMap.queryForObject("selectBigBeansTotalWeight");
	}
	
	//배전두silo BigBeans 총중량 update
	public void updatetBigBeansTotalWeight(int weight)throws SQLException{
		sqlMap.update("updateBigBeansTotalWeight",weight);
	}
	
	//machine 상태 update
	public void updateMachineStatus(HashMap map)throws SQLException{
		sqlMap.update("updateMachineStatus", map);
	}
	
	//machine 상태,대기작업 update
	public void updateMachineWaitingJob(HashMap map)throws SQLException{
		sqlMap.update("updateMachineWaitingJob", map);
	}
	
	//machine 대기작업 select
	public int selectMachineWaitingJob(String machineName)throws SQLException{
		return (Integer)sqlMap.queryForObject("selectMachineWaitingJob",machineName);
	}
	
	//작업 내용 insert
	public void insertJobInfo(JobTO jto)throws SQLException{
		sqlMap.insert("insertJobInfo", jto);
	}
	
	//작업 내용 생산종류포함 insert
	public void insertJobByArticleTypeInfo(JobTO jto)throws SQLException{
		sqlMap.insert("insertJobByArticleTypeInfo", jto);
	}
	
	//작업 내용 생산종류 및 불량 포함 insert
	public void insertJobByArticleTypeFaultInfo(JobTO jto)throws SQLException{
		sqlMap.insert("insertJobByArticleTypeFaultInfo", jto);
	}
	
	//청소 일자 update
	public void updateCleanDate(HashMap map)throws SQLException{
		sqlMap.update("updateCleanDate", map);
	}
	
	
	
	
	//모든재료정보 select
	public ArrayList<BeansTO> selectAllMaterialInfo()throws SQLException{
		return (ArrayList<BeansTO>)sqlMap.queryForList("selectAllMaterialInfo");
	}
	
	//모든재료 갯수 select
	public ArrayList<WeightTO> selectAllMaterialWeightIngo()throws SQLException{
		return (ArrayList<WeightTO>)sqlMap.queryForList("selectAllMaterialWeightInfo");
	}
	
	//모든 머신 정보 select
	public ArrayList<MachineTO> selectAllMachineInfo()throws SQLException{
		return (ArrayList<MachineTO>)sqlMap.queryForList("selectAllMachineInfo");
	}
	
	//모든 silo정보 select
	public ArrayList<SiloTO> selectAllSiloInfo()throws SQLException{
		return (ArrayList<SiloTO>)sqlMap.queryForList("selectAllSiloInfo");
	}
	
	//모든 작업정보 select
	public ArrayList<JobTO> selectAllJobInfo()throws SQLException{
		return (ArrayList<JobTO>)sqlMap.queryForList("selectAllJobInfo");
	}
	
	//특정 작업정보 select
	public ArrayList<JobTO> selectJobInfoByJobName(String jobName)throws SQLException{
		return (ArrayList<JobTO>)sqlMap.queryForList("selectJobInfoByJobName",jobName);
	}
}
